import { S } from '../../s';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSEditor } from '../ipseditor';
import { IPSDEForm } from './ipsdeform';
import { IPSDEFormItem } from './ipsdeform-item';
import { IPSDEFormItemUpdate } from './ipsdeform-item-update';
import { PSDEFormDetailImpl } from './psdeform-detail-impl';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysImage } from '../../res/ipssys-image';

export class PSDEFormItemImpl
  extends PSDEFormDetailImpl
  implements IPSDEFormItem
{
  get caption(): string {
    return this.M.caption;
  }

  get captionItemName(): string {
    return this.M.captionItemName;
  }

  get createDV(): string {
    return this.M.createDV;
  }

  get createDVT():
    | 'SESSION'
    | 'APPLICATION'
    | 'UNIQUEID'
    | 'CONTEXT'
    | 'PARAM'
    | 'OPERATOR'
    | 'OPERATORNAME'
    | 'CURTIME'
    | 'APPDATA' {
    return this.M.createDVT;
  }

  get dataType():
    | 0
    | 1
    | 2
    | 3
    | 4
    | 5
    | 6
    | 7
    | 8
    | 9
    | 10
    | 11
    | 12
    | 13
    | 14
    | 15
    | 16
    | 17
    | 18
    | 19
    | 20
    | 21
    | 22
    | 23
    | 24
    | 25
    | 26
    | 27
    | 28
    | 29 {
    return this.M.dataType;
  }

  get enableCond(): 0 | 1 | 2 | 3 {
    return this.M.enableCond;
  }

  get fieldName(): string {
    return this.M.fieldName;
  }

  get ignoreInput(): number {
    return this.M.ignoreInput;
  }

  get inputTip(): string {
    return this.M.inputTip;
  }

  get inputTipUrl(): string {
    return this.M.inputTipUrl;
  }

  get itemHeight(): number {
    return this.M.itemHeight != null ? this.M.itemHeight : 0.0;
  }

  get itemWidth(): number {
    return this.M.itemWidth != null ? this.M.itemWidth : 0.0;
  }

  get labelCssStyle(): string {
    return this.M.labelCssStyle;
  }

  get labelDynaClass(): string {
    return this.M.labelDynaClass;
  }

  get labelPos(): 'LEFT' | 'TOP' | 'RIGHT' | 'BOTTOM' | 'NONE' {
    return this.M.labelPos;
  }

  get labelWidth(): number {
    return this.M.labelWidth;
  }

  get noPrivDisplayMode(): 1 | 2 {
    return this.M.noPrivDisplayMode;
  }

  get outputCodeListConfigMode(): 0 | 1 | 2 {
    return this.M.outputCodeListConfigMode != null
      ? this.M.outputCodeListConfigMode
      : 0;
  }

  protected phpslanguageres: IPSLanguageRes;
  getPHPSLanguageRes(): IPSLanguageRes | null {
    return (
      this.phpslanguageres ||
      (this.phpslanguageres = this.fillObjectModel(
        S._276,
        this.M.getPHPSLanguageRes,
        S._2ef,
      ) as IPSLanguageRes)
    );
  }

  protected psappdefield: IPSAppDEField;
  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return;
    }
    const ipsdeform = this.getParentPSModelObject(S._23d) as IPSDEForm;
    if (ipsdeform != null) {
      this.psappdefield = ipsdeform
        .getPSAppDataEntity()
        .findPSAppDEField(value);
    }
    return this.psappdefield;
  }

  protected psdeformitemupdate: IPSDEFormItemUpdate;
  getPSDEFormItemUpdate(): IPSDEFormItemUpdate | null {
    if (this.psdeformitemupdate != null) return this.psdeformitemupdate;
    const value = this.M.getPSDEFormItemUpdate;
    if (value == null) {
      return;
    }
    const ipsdeform = this.getParentPSModelObject(S._23d) as IPSDEForm;
    if (ipsdeform != null) {
      this.psdeformitemupdate = ipsdeform.findPSDEFormItemUpdate(value);
    }
    return this.psdeformitemupdate;
  }

  protected pseditor: IPSEditor;
  getPSEditor(): IPSEditor | null {
    return (
      this.pseditor ||
      (this.pseditor = this.fillObjectModel(
        S._12e,
        this.M.getPSEditor,
        S._2f0,
      ) as IPSEditor)
    );
  }

  protected pssysimage: IPSSysImage;
  getPSSysImage(): IPSSysImage | null {
    return (
      this.pssysimage ||
      (this.pssysimage = this.fillObjectModel(
        S._27b,
        this.M.getPSSysImage,
        S._2ad,
      ) as IPSSysImage)
    );
  }

  get resetItemName(): string {
    return this.M.resetItemName;
  }

  protected resetitemnames: string[];
  getResetItemNames(): string[] | null {
    if (this.resetitemnames == null) {
      const value = this.M.resetItemNames;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: string[] = [];
      for (let i = 0; i < arrayNode.length; i++) {
        list.push(arrayNode[i]);
      }
      this.resetitemnames = list;
    }
    return this.resetitemnames.length == 0 ? null : this.resetitemnames;
  }

  get unitName(): string {
    return this.M.unitName;
  }

  get unitNameWidth(): number {
    return this.M.unitNameWidth != null ? this.M.unitNameWidth : 0;
  }

  get updateDV(): string {
    return this.M.updateDV;
  }

  get updateDVT():
    | 'SESSION'
    | 'APPLICATION'
    | 'UNIQUEID'
    | 'CONTEXT'
    | 'PARAM'
    | 'OPERATOR'
    | 'OPERATORNAME'
    | 'CURTIME'
    | 'APPDATA' {
    return this.M.updateDVT;
  }

  get valueFormat(): string {
    return this.M.valueFormat;
  }

  get valueItemName(): string {
    return this.M.valueItemName;
  }

  get allowEmpty(): boolean {
    return this.M.allowEmpty;
  }

  get compositeItem(): boolean {
    return this.M.compositeItem != null ? this.M.compositeItem : false;
  }

  get convertToCodeItemText(): boolean {
    return this.M.convertToCodeItemText != null
      ? this.M.convertToCodeItemText
      : false;
  }

  get emptyCaption(): boolean {
    return this.M.emptyCaption != null ? this.M.emptyCaption : false;
  }

  get enableAnchor(): boolean {
    return this.M.enableAnchor != null ? this.M.enableAnchor : false;
  }

  get enableInputTip(): boolean {
    return this.M.enableInputTip != null ? this.M.enableInputTip : false;
  }

  get enableItemPriv(): boolean {
    return this.M.enableItemPriv != null ? this.M.enableItemPriv : false;
  }

  get enableUnitName(): boolean {
    return this.M.enableUnitName != null ? this.M.enableUnitName : false;
  }

  get hidden(): boolean {
    return this.M.hidden != null ? this.M.hidden : false;
  }

  get inputTipClosable(): boolean {
    return this.M.inputTipClosable != null ? this.M.inputTipClosable : false;
  }

  get needCodeListConfig(): boolean {
    return this.M.needCodeListConfig != null
      ? this.M.needCodeListConfig
      : false;
  }

  get showCaption(): boolean {
    return this.M.showCaption != null ? this.M.showCaption : false;
  }
  get cls(): string {
    return 'PSDEFormItemImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._b6) return true;
    return super.instanceof(cls);
  }
}
